<template>
  <div class="app-container">
    <el-table :data="productList" style="width: 100%">
      <el-table-column label="序号" width="80" align="center">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.$index + 1 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="下单时间" width="180" align="center">
        <template slot-scope="scope">
          <i class="el-icon-time"></i>
          <span style="margin-left: 10px">{{ scope.row.productlistTime }}</span>
        </template>
      </el-table-column>
      <el-table-column label="商品名称" width="180" align="center">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.orderlistProduct }}</span>
        </template>
      </el-table-column>
      <el-table-column label="收货地址" wQidth="300" align="center">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.addressDetail }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center">
        <template slot-scope="scope">
          <el-button size="mini" @click="viewDetails(scope.row.productlistId)">查看详情</el-button>
          <!-- <el-button size="mini" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
          <el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button> -->
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页 -->
    <div class="paging" style="float: right;">
      <el-pagination @current-change="handleCurrentChange" :current-page.sync="pageNum" :page-size="10"
        layout="total, prev, pager, next" :total="total">
      </el-pagination>
    </div>
    <!-- 详情 -->
    <el-dialog title="订单详情" :visible.sync="dialogTableVisible">
      <el-form :model="detailList">
        <el-form-item label="用户名" :label-width="formLabelWidth">
          <el-input v-model="detailList.userName" autocomplete="off" disabled></el-input>
        </el-form-item>
        <el-form-item label="商品名称" :label-width="formLabelWidth">
          <el-input v-model="detailList.productName" autocomplete="off" disabled></el-input>
        </el-form-item>
        <el-form-item label="商品价格" :label-width="formLabelWidth">
          <el-input v-model="detailList.orderlistCount" autocomplete="off" disabled></el-input>
        </el-form-item>
        <el-form-item label="商品价格" :label-width="formLabelWidth">
          <el-input v-model="detailList.productPrice" autocomplete="off" disabled></el-input>
        </el-form-item>
      </el-form>

    </el-dialog>
  </div>
</template>
<script>
import { selectAll, showDetail } from '../../api/order/order.js'
export default {
  data() {
    return {
      detailList: [],
      productList: [],
      dialogTableVisible: false,
      pageNum: 1,
      total: 100,
      formLabelWidth: "130px"
    }
  },
  methods: {
    handleCurrentChange(val) {
      this.pageNum = val;
      this.selectAll_();
      console.log(`当前页: ${val}`);
    },
    handleEdit(index, row) {
      console.log(index, row);
    },
    handleDelete(index, row) {
      console.log(index, row);
    },
    async viewDetails(id) {
      let res = await showDetail(id);
      console.log(res)
      this.detailList = res.data[0];
      this.dialogTableVisible = true;
    },
    // 查询所有
    async selectAll_() {
      let res = await selectAll(this.pageNum);
      console.log(res)
      this.productList = res.data.list;
      this.total = res.data.total;
    },
  },
  created() {
    this.selectAll_()
  },
}
</script>
<style>
.paging {
  margin-top: 20px;
}
</style>